<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>双问号语法</title>
</head>
<body>
<script>
    <!--        TODO:判断null 和undefined-->
    console.log(1 || "xx") 			//1
    console.log(0 || "xx") 			//xx
    console.log(null || "xx")		//xx
    console.log(undefined || "xx")  //xx
    console.log(-1 || "xx") 		//-1
    console.log("" || "xx") 		//xx

    console.log(1 ?? "xx")			//1
    console.log(0 ?? "xx") 			//0
    console.log(null ?? "xx") 		//xx
    console.log(undefined ?? "xx")  //xx
    console.log(-1 ?? "xx") 		//-1
    console.log("" ?? "xx") 		//''



    const foo = null ?? 'my school';
    console.log('%c   foo: ', 'color: MidnightBlue; background: Aquamarine; font-size: 20px;', foo);
    // 输出: "my school"

    const baz = 0 ?? 42;
    console.log('%c   baz: ', 'color: MidnightBlue; background: Aquamarine; font-size: 20px;', baz);

</script>
</body>
</html>